import Util from "./Util";
import { UserData } from "./UserData";

export default class Adapter {
    name:string='adapter default';
    /**
     * 用户ID
    */
    uid:string="";
    constructor() { }
    /**
     * 自动登录,获取UID
    */
    autoLogin(){
        Util.postData("game/api/login",{"mtid":Util.getMathineId()}).then((data)=>{
            this.uid = data.uid;
            UserData.instance.userId = this.uid;
        }).catch((msg)=>{
            Util.log("login error:",msg);
        });
    }

    showAd(): void {
        console.log('Adapter show ad');
    }

    save(data) {
        console.log('Adapter send score');
        if (data.onSuccess) {
            data.onSuccess.call(this);
        }
    }
    
    getFriends(data:any):boolean {
        console.log('Adapter get friends');
        return false;
    }

    init() {

    }

    /**开始分包加载*/
    loadSubRes(list, handler):void {
        handler.run();
    }

    hasVidoAd():boolean {
        return false;
    }



    showNormalToprank():void {

    }

    showPopupToprank() {

    }

    share() {
        console.log('Adapter share');
    }

    login(callback) {
        console.log('Adapter login');
        callback && callback.runWith({ nickName: "我" });
    }

    loadLvlData(key) {

    }

    saveLvlData(lvl, data) {

    }

    freshMyScore(score) {

    }


    getUid() {
        if(this.uid){
            return this.uid;
        }
        return 0;
    }

    showBannerAd(left, top, width) { }
    hideBannerAd() { }

    //显示推荐组件
    showBannerTj() { }
    //隐藏推荐组件
    hideBannerTj() { }

    //显示弹出组件
    showPortalTj() { }

    //激励广告
    showVideoAd(handler) { }

    //插屏广告
    showInsertAd() { }

}